<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/include/page.jsp"%>
<jsp:useBean id="pojo" class="com.jjh.users.pojo.ASelectCourse"/>
<!DOCTYPE HTML>
<html>
	<head>
		<%@include file="/common/include/header.jsp"%>
		<%@include file="/common/include/title.jsp"%>
		
		<title>课程管理-------课程列表</title>
	</head>
	<body>
		<nav class="breadcrumb">
			<span class="c-gray en">&gt;</span> 课程管理
			<span class="c-gray en">&gt;</span> 课程列表
			<a class="btn btn-success radius r" style="line-height: 1.6em; margin-top: 3px"
				href="javascript:location.replace(location.href);" title="刷新">
				<i class="Hui-iconfont">&#xe68f;</i>
			</a>
		</nav>
		<div class="page-container">
			<form method="post" action="${rootPath }/back/teachers/selectCourseList">
				<div class="text-c">
					<input type="text" class="input-text" style="width: 250px"
						placeholder="输入关键字" id="" name="keyword" value="${requestScope.keyword }">
					<span class="select-box inline">
						状态:
						<select name="status" class="select">
							<option value="">请选择</option>
							<c:forEach items="${pojo.enumsMap }" var="me" varStatus="stat">
								<%-- me:map中的entrySet ;me.key:键,me.value:值--%>
								<c:if test="${fn:startsWith(me.key,'STATUS_')}">
									<c:set value="${fn:split(me.key, '-') }" var="keys"/>
									<!-- 如何获取到枚举中的值
										map的键是:枚举项-code值,值是:info
									 -->
									<option value="${keys[1]}" ${requestScope.status == keys[1] ? 'selected' : '' }>${me.value }</option>
								</c:if>
							</c:forEach>
						</select>
					</span>
					日期范围：
					<input type="text" name="st" readonly="readonly" value="${requestScope.st }"
						onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
						id="datemin" class="input-text Wdate" style="width: 170px;">
					- <input type="text" name="ed" readonly="readonly" value="${requestScope.ed }"
						onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
						id="datemax" class="input-text Wdate" style="width: 170px;">
					<button type="submit" class="btn btn-success radius" id="" name="">
						<i class="Hui-iconfont">&#xe665;</i> 搜索
					</button>
				</div>
			</form>
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
					<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
						<i class="Hui-iconfont">&#xe6e2;</i>
						批量删除
					</a>
					<a href="javascript:;" onclick="member_add('添加管理员','${rootPath}/back/teachers/coursesInsert','','510')"
						class="btn btn-primary radius">
						<i class="Hui-iconfont">&#xe600;</i>
						添加课程
					</a>
				</span>
				<span class="r">共有数据：<strong>${requestScope.pageInfoUtil.totalRecord }</strong>条</span>
			</div>
			
			
			<div class="mt-20">
				<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper no-footer">
					<form id="form">
						
							<table class="table table-border table-bordered table-hover table-bg table-sort">
								<thead>
									<tr class="text-c">
										<th width="25"><input type="checkbox" name="" value=""></th>
										<th width="50">ID</th>
										<th width="200">学生id</th>
										<th width="200">课程id</th>
										<th width="200">课程名字</th>
										<th width="100">分数</th>
										<th width="80">状态</th>
										<th width="200">创建时间</th>
										<th width="200">发布时间</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${requestScope.list }" var="listTemp" varStatus="stat">
										<c:choose>
											<c:when test="${listTemp.studentsId  == sessionScope.StudentsSess.id }">
												<tr class="text-c">
													<td><input type="checkbox" value="1" name=""></td>
													<td>${listTemp.id }</td>
													<td>${listTemp.studentsId }</td>
													<td>${listTemp.classId}</td>
													<td>${listTemp.course.name }</td>
													<td>${listTemp.clasScore}</td>
													<td class="td-status">
														<span class="label label-success radius">
															${listTemp.statusStr }
														</span>
													</td>
													<td><fmt:formatDate value="${listTemp.createTime }" pattern="${dateTimeFormat }"/></td>
													<td><fmt:formatDate value="${listTemp.pubTime }" pattern="${dateTimeFormat }"/></td>
												</tr>
											</c:when>
										</c:choose>
									</c:forEach>
								</tbody>
							</table>
						
					</form>
					<div class="dataTables_info" id="DataTables_Table_0_info"
						role="status" aria-live="polite">共${requestScope.pageInfoUtil.totalPage }页，共${requestScope.pageInfoUtil.totalRecord } 条
					</div>
					<form method="post" id="pageForm" action="${rootPath }/back/teachers/coursesList">
						<input type="hidden" name="keyword" value="${requestScope.keyword }">
						<input type="hidden" name="status" value="${requestScope.status }">
						<input type="hidden" name="st" value="${requestScope.st }">
						<input type="hidden" name="ed" value="${requestScope.ed }">
						
						<div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
							<a class="paginate_button previous disabled"
								aria-controls="DataTables_Table_0" data-dt-idx="0" tabindex="0"
								onclick="return pageFormSubmit('pageForm','currentPage','1','pageSize','${requestScope.pageInfoUtil.pageSize }')"
								id="DataTables_Table_0_previous">首页</a>
							<a class="paginate_button previous disabled"
								aria-controls="DataTables_Table_0" data-dt-idx="0" tabindex="0"
								onclick="return pageFormSubmit('pageForm','currentPage','${requestScope.pageInfoUtil.prePage }','pageSize','${requestScope.pageInfoUtil.pageSize }')"
								id="DataTables_Table_0_previous">上一页</a>
							<a class="paginate_button next" 
								aria-controls="DataTables_Table_0" data-dt-idx="3" tabindex="0" 
								onclick="return pageFormSubmit('pageForm','currentPage','${requestScope.pageInfoUtil.nextPage }','pageSize','${requestScope.pageInfoUtil.pageSize }')"
								id="DataTables_Table_0_next">下一页</a>
							<a class="paginate_button previous disabled"
								aria-controls="DataTables_Table_0" data-dt-idx="0" tabindex="0"
								onclick="return pageFormSubmit('pageForm','currentPage','${requestScope.pageInfoUtil.totalPage }','pageSize','${requestScope.pageInfoUtil.pageSize }')"
								id="DataTables_Table_0_previous">尾页</a>
							第<input type="text" class="paginate_button" name="currentPage" id="currentPage" size="5" maxlength="5" value="${requestScope.pageInfoUtil.currentPage }">页
							每页<input type="text" class="paginate_button" name="pageSize" id="pageSize" size="5" maxlength="5" value="${requestScope.pageInfoUtil.pageSize }">条
							<input type="submit" class="paginate_button" value="GO"/>
						</div>
					</form>
				</div>
			</div>
		</div>
		<%@include file="/common/include/footer.jsp"%>
		<script type="text/javascript">
			function pageFormSubmit(formId,currentPageId,currentPageVal,pageSizeId,pageSizeVal)
			{
				$("#" + currentPageId).val(currentPageVal);
				$("#" + pageSizeId).val(pageSizeVal);
				/* 提交表单 */
				$("#" + formId).submit();
				return false ; 
			}
		</script>
		<!--请在下方写此页面业务相关的脚本-->
		<script type="text/javascript" src="${rootPath }/common/resource/lib/My97DatePicker/4.8/WdatePicker.js"></script>
		<script type="text/javascript" src="${rootPath }/common/resource/lib/datatables/1.10.15/jquery.dataTables.min.js"></script>
		<script type="text/javascript" src="${rootPath }/common/resource/lib/laypage/1.2/laypage.js"></script>
		<script type="text/javascript">
		$(function(){
			$('.skin-minimal input').iCheck({
				checkboxClass: 'icheckbox-blue',
				radioClass: 'iradio-blue',
				increaseArea: '20%'
			});
			
			/*
				表单验证的框架;
				$();id选择器
			*/
			$("#form").validate({
				/* rules:规则 */
				rules:{
					/* 表单中input的name的值,不是id的值 */
					trueName:{
						/* 必须填写 */
						required:true,
						/* 最小长度 */
						minlength:2,
						/* 最大长度 */
						maxlength:16
					},
					/* 性别必填 */
					sex:{
						required:true,
					},
					/* 性别必填 */
					phone:{
						required:true,
						/* 是手机号;必须是符合要求的手机号 */
						isPhone:true,
					},
					/* 邮箱 */
					email:{
						/* 必须填写 */
						required:true,
						/* 是邮箱 */
						email:true,
					},
					/* 角色 */
					adminRole:{
						required:true,
					},
				},
				onkeyup:false,
				focusCleanup:true,
				success:"valid",
				submitHandler:function(form){
					$(form).ajaxSubmit({
						type: 'post',
						/* url: "${rootPath}/back/AdminsBackServlet?method=adminsInsertSubmit" , */
						success: function(data){
							/**
								参数1:提示信息
								参数2:弹出信息的可选项;time:超时
								参数3:执行完以后调用此方法
							*/
							layer.msg(data.info,{icon:1,time:3000},function()
							{
								/* 成功 */
								if(data.code == '0')
								{
									/* 刷新父窗口 */
									var index = parent.layer.getFrameIndex(window.name);
									parent.$('.btn-refresh').click();
									/* 关闭当前窗口 */
									parent.layer.close(index);
								}
							});
						},
		                error: function(XmlHttpRequest, textStatus, errorThrown){
							layer.msg('error!',{icon:1,time:1000});
						},
						dataType:'json'
					});
				}
			});
		});
		</script> 
		<script type="text/javascript">
			/*用户-添加*/
			function member_add(title, url, w, h) {
				/*
					参数1:标题
					参数2:url
					参数3：宽度,
					参数4:高度
				*/
				layer_show(title, url, w, h);
			}
			/*用户-查看*/
			function member_show(title, url, id, w, h) {
				layer_show(title, url, w, h);
			}
			/*用户-停用*/
			function member_stop(obj, id) {
				layer
						.confirm(
								'确认要停用吗？',
								function(index) {
									$
											.ajax({
												type : 'POST',
												url : '',
												dataType : 'json',
												success : function(data) {
													$(obj)
															.parents("tr")
															.find(".td-manage")
															.prepend(
																	'<a style="text-decoration:none" onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
													$(obj)
															.parents("tr")
															.find(".td-status")
															.html(
																	'<span class="label label-defaunt radius">已停用</span>');
													$(obj).remove();
													layer.msg('已停用!', {
														icon : 5,
														time : 1000
													});
												},
												error : function(data) {
													console.log(data.msg);
												},
											});
								});
			}
	
			/*用户-启用*/
			function member_start(obj, id) {
				layer
						.confirm(
								'确认要启用吗？',
								function(index) {
									$
											.ajax({
												type : 'POST',
												url : '',
												dataType : 'json',
												success : function(data) {
													$(obj)
															.parents("tr")
															.find(".td-manage")
															.prepend(
																	'<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>');
													$(obj)
															.parents("tr")
															.find(".td-status")
															.html(
																	'<span class="label label-success radius">已启用</span>');
													$(obj).remove();
													layer.msg('已启用!', {
														icon : 6,
														time : 1000
													});
												},
												error : function(data) {
													console.log(data.msg);
												},
											});
								});
			}
			/*用户-编辑*/
			function member_edit(title, url, id, w, h) {
				layer_show(title, url, w, h);
			}
			/*密码-修改*/
			function change_password(title, url, id, w, h) {
				layer_show(title, url, w, h);
			}
			/*用户-删除*/
			function member_del(obj, id) {
				layer.confirm('确认要删除吗？', function(index) {
					$.ajax({
						type : 'POST',
						url : '',
						dataType : 'json',
						success : function(data) {
							$(obj).parents("tr").remove();
							layer.msg('已删除!', {
								icon : 1,
								time : 1000
							});
						},
						error : function(data) {
							console.log(data.msg);
						},
					});
				});
			}
		</script>
	</body>
</html>